
using System.Reflection;
using QdbTool.Core;
using QdbTool.Tests.Core;
using QdbUnit;
using Mono.Cecil;

namespace QdbTool.Tests.TA
{
	internal abstract class TATestCaseBase : ITestCase
	{
		protected AssemblyDefinition GenerateAssembly(string resourceName, params Assembly[] references)
		{
			return AssemblyFactory.GetAssembly(
						CompilationServices.EmitAssemblyFromResource(
							ResourceServices.CompleteResourceName(
													GetType(),
													resourceName), references));
		}

		protected static void InstrumentAssembly(AssemblyDefinition testAssembly)
		{
			InstrumentationContext context = new InstrumentationContext(Configuration(testAssembly.MainModule.Image.FileInformation.FullName), testAssembly);
			new QdbTool.TA.TAInstrumentation().Run(context);
		}

		protected static Configuration Configuration(string assemblyLocation)
		{
			return new Configuration(assemblyLocation);
		}
	}
}
